package com.deyinet.bdcms.core.common;

/**
 * Created by Administrator on 2017/3/27 0027.
 */
import com.deyinet.bdcms.core.bean.EntityToVo;
import com.deyinet.bdcms.core.vo.Page;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class EntityTool {
    public EntityTool() {
    }

    public List<?> createEntityToVoList(Class<? extends EntityToVo> cs, List list) {
        ArrayList<Object> rs = new ArrayList();
        Iterator var4 = list.iterator();

        while(var4.hasNext()) {
            Object o = var4.next();
            Object entityToVo = this.createEntityToVo(cs, new Object[]{o});
            rs.add(entityToVo);
        }

        return rs;
    }

    public EntityToVo createEntityToVo(Class<? extends EntityToVo> cs, Object... datas) {
        try {
            EntityToVo entityToVo = (EntityToVo)cs.newInstance();
            entityToVo.loadData(datas);
            return entityToVo;
        } catch (InstantiationException var4) {
            var4.printStackTrace();
        } catch (IllegalAccessException var5) {
            var5.printStackTrace();
        }

        return null;
    }

    public Page<EntityToVo> getPageEntityToVo(Class<? extends EntityToVo> cs, Page<?> page) {
        Page<EntityToVo> entityToVoPage = new Page();
        entityToVoPage.setTotalRow(page.getTotalRow());
        entityToVoPage.setPageCurrent(page.getPageCurrent());
        entityToVoPage.setPageSize(page.getPageSize());
        List list = this.createEntityToVoList(cs, page.getList());
        entityToVoPage.setList(list);
        return entityToVoPage;
    }
}
